// Copyright 2014 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef PERMISSION_BROKER_HID_BASICTYPES_H_
#define PERMISSION_BROKER_HID_BASICTYPES_H_

#include <stdint.h>

namespace permission_broker {

static const int kHidMaxDescriptorSize = 4096;

struct HidReportDescriptor {
  int size;
  uint8_t data[kHidMaxDescriptorSize];
};

struct HidUsage {
  enum Page {
    PAGE_UNDEFINED = 0x00,
    PAGE_GENERIC_DESKTOP = 0x01,
    PAGE_SIMULATION = 0x02,
    PAGE_VIRTUAL_REALITY = 0x03,
    PAGE_SPORT = 0x04,
    PAGE_GAME = 0x05,
    PAGE_KEYBOARD = 0x07,
    PAGE_LED = 0x08,
    PAGE_BUTTON = 0x09,
    PAGE_ORDINAL = 0x0a,
    PAGE_TELEPHONY = 0x0b,
    PAGE_CONSUMER = 0x0c,
    PAGE_DIGITIZER = 0x0d,
    PAGE_PID_PAGE = 0x0f,
    PAGE_UNICODE = 0x10,
    PAGE_ALPHANUMERIC_DISPLAY = 0x14,
    PAGE_MEDICAL_INSTRUMENTS = 0x40,
    PAGE_MONITOR_0 = 0x80,
    PAGE_MONITOR_1 = 0x81,
    PAGE_MONITOR_2 = 0x82,
    PAGE_MONITOR_3 = 0x83,
    PAGE_POWER_0 = 0x84,
    PAGE_POWER_1 = 0x85,
    PAGE_POWER_2 = 0x86,
    PAGE_POWER_3 = 0x87,
    PAGE_BAR_CODE_SCANNER = 0x8c,
    PAGE_SCALE = 0x8d,
    PAGE_MAGNETIC_STRIPE_READER = 0x8e,
    PAGE_RESERVED_POINT_OF_SALE = 0x8f,
    PAGE_CAMERA_CONTROL = 0x90,
    PAGE_ARCADE = 0x91,
    PAGE_VENDOR = 0xff00,
    PAGE_MEDIA_CENTER = 0xffbc,
  };

  // These usage enumerations are derived from the HID Usage Tables v1.11 spec.
  enum GenericDesktopUsage {
    GENERIC_DESKTOP_USAGE_UNDEFINED = 0x00,
    GENERIC_DESKTOP_USAGE_POINTER = 0x01,
    GENERIC_DESKTOP_USAGE_MOUSE = 0x02,
    GENERIC_DESKTOP_USAGE_JOYSTICK = 0x04,
    GENERIC_DESKTOP_USAGE_GAME_PAD = 0x05,
    GENERIC_DESKTOP_USAGE_KEYBOARD = 0x06,
    GENERIC_DESKTOP_USAGE_KEYPAD = 0x07,
    GENERIC_DESKTOP_USAGE_MULTI_AXIS_CONTROLLER = 0x08,
    GENERIC_DESKTOP_USAGE_X = 0x30,
    GENERIC_DESKTOP_USAGE_Y = 0x31,
    GENERIC_DESKTOP_USAGE_Z = 0x32,
    GENERIC_DESKTOP_USAGE_RX = 0x33,
    GENERIC_DESKTOP_USAGE_RY = 0x34,
    GENERIC_DESKTOP_USAGE_RZ = 0x35,
    GENERIC_DESKTOP_USAGE_SLIDER = 0x36,
    GENERIC_DESKTOP_USAGE_DIAL = 0x37,
    GENERIC_DESKTOP_USAGE_WHEEL = 0x38,
    GENERIC_DESKTOP_USAGE_HAT_SWITCH = 0x39,
    GENERIC_DESKTOP_USAGE_COUNTED_BUFFER = 0x3a,
    GENERIC_DESKTOP_USAGE_BYTE_COUNT = 0x3b,
    GENERIC_DESKTOP_USAGE_MOTION_WAKEUP = 0x3c,
    GENERIC_DESKTOP_USAGE_START = 0x3d,
    GENERIC_DESKTOP_USAGE_SELECT = 0x3e,
    GENERIC_DESKTOP_USAGE_VX = 0x40,
    GENERIC_DESKTOP_USAGE_VY = 0x41,
    GENERIC_DESKTOP_USAGE_VZ = 0x42,
    GENERIC_DESKTOP_USAGE_VBRX = 0x43,
    GENERIC_DESKTOP_USAGE_VBRY = 0x44,
    GENERIC_DESKTOP_USAGE_VBRZ = 0x45,
    GENERIC_DESKTOP_USAGE_VNO = 0x46,
    GENERIC_DESKTOP_USAGE_SYSTEM_CONTROL = 0x80,
    GENERIC_DESKTOP_USAGE_SYSTEM_POWER_DOWN = 0x81,
    GENERIC_DESKTOP_USAGE_SYSTEM_SLEEP = 0x82,
    GENERIC_DESKTOP_USAGE_SYSTEM_WAKEUP = 0x83,
    GENERIC_DESKTOP_USAGE_SYSTEM_CONTEXT_MENU = 0x84,
    GENERIC_DESKTOP_USAGE_SYSTEM_MAIN_MENU = 0x85,
    GENERIC_DESKTOP_USAGE_SYSTEM_APP_MENU = 0x86,
    GENERIC_DESKTOP_USAGE_SYSTEM_MENU_HELP = 0x87,
    GENERIC_DESKTOP_USAGE_SYSTEM_MENU_EXIT = 0x88,
    GENERIC_DESKTOP_USAGE_SYSTEM_MENU_SELECT = 0x89,
    GENERIC_DESKTOP_USAGE_SYSTEM_MENU_RIGHT = 0x8a,
    GENERIC_DESKTOP_USAGE_SYSTEM_MENU_LEFT = 0x8b,
    GENERIC_DESKTOP_USAGE_SYSTEM_MENU_UP = 0x8c,
    GENERIC_DESKTOP_USAGE_SYSTEM_MENU_DOWN = 0x8d,
    GENERIC_DESKTOP_USAGE_SYSTEM_COLD_RESTART = 0x8e,
    GENERIC_DESKTOP_USAGE_SYSTEM_WARM_RESTART = 0x8f,
    GENERIC_DESKTOP_USAGE_DPAD_UP = 0x90,
    GENERIC_DESKTOP_USAGE_DPAD_DOWN = 0x91,
    GENERIC_DESKTOP_USAGE_DPAD_LEFT = 0x92,
    GENERIC_DESKTOP_USAGE_DPAD_RIGHT = 0x93,
    GENERIC_DESKTOP_USAGE_SYSTEM_DOCK = 0xa0,
    GENERIC_DESKTOP_USAGE_SYSTEM_UNDOCK = 0xa1,
    GENERIC_DESKTOP_USAGE_SYSTEM_SETUP = 0xa2,
    GENERIC_DESKTOP_USAGE_SYSTEM_BREAK = 0xa3,
    GENERIC_DESKTOP_USAGE_SYSTEM_DEBUGGER_BREAK = 0xa4,
    GENERIC_DESKTOP_USAGE_APPLICATION_BREAK = 0xa5,
    GENERIC_DESKTOP_USAGE_APPLICATION_DEBUGGER_BREAK = 0xA6,
    GENERIC_DESKTOP_USAGE_SYSTEM_SPEAKER_MUTE = 0xa7,
    GENERIC_DESKTOP_USAGE_SYSTEM_HIBERNATE = 0xa8,
    GENERIC_DESKTOP_USAGE_SYSTEM_DISPLAY_INVERT = 0xb0,
    GENERIC_DESKTOP_USAGE_SYSTEM_DISPLAY_INTERNAL = 0xb1,
    GENERIC_DESKTOP_USAGE_SYSTEM_DISPLAY_EXTERNAL = 0xb2,
    GENERIC_DESKTOP_USAGE_SYSTEM_DISPLAY_BOTH = 0xb3,
    GENERIC_DESKTOP_USAGE_SYSTEM_DISPLAY_DUAL = 0xb4,
    GENERIC_DESKTOP_USAGE_SYSTEM_DISPLAY_TOGGLE = 0xb5,
    GENERIC_DESKTOP_USAGE_SYSTEM_DISPLAY_SWAP = 0xb6,
  };

  HidUsage(Page page, uint16_t usage)
      : page(page), usage(usage) {}
  ~HidUsage() = default;

  Page page;
  uint16_t usage;
};

}  // namespace permission_broker

#endif  // PERMISSION_BROKER_HID_BASICTYPES_H_
